#pragma once
#include "InternalsPlugin.hpp"
#include "Sprite.hpp"
#include "TypeDefs.hpp"

struct OvertakeEvent {
	char winnerName[32];
	char looserName[32];
	unsigned char oldWinnerPlace;
	unsigned char newWinnerPlace;
	double overtakeET;
	long winnerIDToReplay;
};

class WidgetOvertake
{
public:
	WidgetOvertake(const char *pRootPath, const char *pIniUIFilename, const char *pIniDriverMappingFilename, const char *pIniVehiculeClassMappingFilename);
	~WidgetOvertake(void);

	void init(const ScreenInfoV01 &info, float ratio, float ratioWidth, float ratioHeight, Sprite spriteList[]);
	void updateData(double mET);
	void render(int profileIndex, const ScreenInfoV01 &info, const LPD3DXFONT *fontList, const D3DCOLOR *colorList, Sprite spriteList[], double mET); 
	void addEvent(double mET, DriverInfo & looserDi, DriverInfo & winnerDi, unsigned char oldWinnerPlace, unsigned char newWinnerPlace, double overtakeET);
//private:
  bool initialized;
 
  	int nbProfiles;
	PluginProfile profiles[10];

	RECT tmpRect;

 const char *rootPath;
  char iniUIFilename[800];

  int nbEvent;
  double startEventET;
  OvertakeEvent eventList[51];
  int eventBufferSize;
  int animRayonSize;
  double secondOfBeforeAnimation;
  double secondForAnimation;
  double secondOfAfterAnimation;

  bool playingEvent;
  int inhibitionDelay;
  double currentReplayET;
  long idToViewInReplay;
  // widget
  bool available;
  ImageData bgImageData;

  // frontPlace
  bool frontPlaceAvailable;
  TextData frontPlaceTextData;
  char frontPlace[4];
  // backPlace
  bool backPlaceAvailable;
  TextData backPlaceTextData;
  char backPlace[4];
 
  // winner driver name
  bool winnerNameAvailable;
  ImageData winnerNameImageData;
  TextData winnerNameTextData;
	int animWinnerOffsetX;
	int animWinnerOffsetY;
  // looser driver name
  bool looserNameAvailable;
  ImageData looserNameImageData;
  TextData looserNameTextData;
	int animLooserOffsetX;
	int animLooserOffsetY;
    // tools
  char tmp[1000];
};

